Re: [GENERAL] Updating multiple fields - Mailing list pgsql-general

From lynch@lscorp.com (Richard Lynch)
Subject Re: [GENERAL] Updating multiple fields
Date
Msg-id v02140b73b1b94e8e4af0@[207.152.64.133]
Whole thread Raw
List pgsql-general
At 10:20 AM 6/26/98, Joao Paulo Felix wrote:
>Hello there,
>
>I have the following fields description, info and title.
>Is there a PostgreSQL query to update more than one field at the same
>time?
>
>Right now I have the following (I am using it with PHP, so please
>desregard its code):
>
>pg_Exec($conn, "UPDATE options SET description = '$description'
>        WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET info = '$info'
>        WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET title = '$title'
>        WHERE product = '$product' AND title = '$old_title';");

Hey!  One I can answer!

typos may exist:

pg_Exec($conn, "UPDATE options SET description = '$description', info =
'$info', title = '$title' WHERE product = '$product' AND title =
'$old_title'");

Basically, you can have as many ", field = $value" entries as you like.

I also purposefully stripped off the ';' inside the string because
PostgreSQL doesn't need it, and some other database backend barfs when you
use it, so if you ever want to port, you don't want the ';' as part of the
SQL.  Capiche?

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



pgsql-general by date:

Previous
From: Joao Paulo Felix
Date:
Subject: Updating multiple fields
Next
From: Brian
Date:
Subject: Are there any books